<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<script>

const graph = {
    0:[1,2],
    1:[2],
    2:[0,3],
    3:[3]
}

const visited = new Set()

let dfs = (n) => {
    console.log(n)
    visited.add(n)
    graph[n].forEach((c) => {
        if(!visited.has(c)){
            dfs(c)
        }
    })
}

dfs(2)


</script>
</body>
</html>